use serde_derive::{Serialize, Deserialize};
use rust_admin2_common::{
    models::{UserRow as ModelRow},
    json::JsonPager
};
use sqlx::{postgres::{PgRow}, row::Row,};
use crate::common::{Pool, models::BackendModel};

#[derive(Serialize, Deserialize, Debug)]
pub struct User;

impl BackendModel<ModelRow> for User { 
    
    const TABLE_NAME: &'static str = "users";
    const FIELDS: &'static str = "id, name, login_count, last_login, last_ip, status, created, updated";

    fn get_row_filter(r: &PgRow) -> ModelRow {
        unfold_fields!(r, {
            id => i32,
            name => String,
            login_count => i32,
            status => i16,
        }, {}, {last_login, created, updated,}, {}, {last_ip,})
    }
}

impl User {

    record_list!();
}
